package com.ruoyi.imweb.controller;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.imweb.domain.ImUserVO;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/user")
public class ImUserController extends BaseController {
    @Autowired
    private SysUserMapper userMapper;
    @GetMapping("/list")
    public AjaxResult list(SysUser user)
    {
        user.setUserType("01");
        List<SysUser> list = userMapper.selectUserList(user);
        return AjaxResult.success(list.stream().map(a-> {
            ImUserVO imUserVO = BeanUtil.copyProperties(a, ImUserVO.class);
            imUserVO.setUsername(a.getNickName());
            imUserVO.setId(a.getUserId());
            return imUserVO;
        }).collect(Collectors.toList()));
    }
}
